package com.wr.recruit.service.service.impl;

import com.wr.recruit.service.dao.repo.UserRepo;
import com.wr.recruit.service.service.LoginService;
import com.wr.recruit.service.utils.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginServiceImpl implements LoginService {

    private UserRepo userRepo;

    @Autowired
    public LoginServiceImpl(UserRepo userRepo) {
        this.userRepo = userRepo;
    }

    @Override
    public Boolean login(String userName, String password, String loginPassword) {
        String key = generatePassword(userName,loginPassword);
        if (password.equals(key))
            return true;
        return false;
    }

    private String generatePassword(String userName, String password){
        String key = userName + password;
        return MD5Util.MD5(key);
    }
}
